package com.yzd.learnjava.containers;

import java.util.Iterator;
import java.util.TreeMap;

import com.yzd.learnjava.util.CountingMapData;
import com.yzd.learnjava.util.Print;

import sun.util.logging.resources.logging;

public class SortedMapDemo {
	public static void main(String[] args) {
		TreeMap<Integer, String> sortedMap = new TreeMap<Integer, String>(new CountingMapData(10));
		Print.print(sortedMap);
		
		Integer low = sortedMap.firstKey();
		Integer high = sortedMap.lastKey();
		Print.print("low : " + low + ", high:" + high);
		
		Iterator<Integer> it = sortedMap.keySet().iterator();
		for(int i = 0 ; i <= 6; i++) {
			if(i == 3)low = it.next();
			if(i == 6)high = it.next();
			else it.next();
		}
		Print.print("low : " + low + ", high:" + high);
		Print.print("sub : " + sortedMap.subMap(low, high));
		Print.print("head : " + sortedMap.headMap(high));
		Print.print("tail : " + sortedMap.tailMap(low));
	}
}
